package diamondRingServlet;

import com.alibaba.fastjson.JSON;
import diamondRingEntity.Admin;
import diamondRingService.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/*
删除用户
 */
@WebServlet("/BackDeleteServlet")
public class BackDeleteServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        AdminServiceImpl adminService=new AdminServiceImpl();

        int count = 0;
        String ID = request.getParameter("ID");
        if (adminService.DeleteIdAdmin(ID)>0){
            out.print("<script>\n" +
                    "    location.href=\"http://localhost:8080/DiamondRing/back-stage-Management/userList.html\"\n" +
                    "    alert(\"删除成功!\");\n" +
                    "</script>");
        }else{
            out.print("<script>\n" +
                    "    location.href=\"http://localhost:8080/DiamondRing/back-stage-Management/userList.html\"\n" +
                    "    alert(\"删除失败!\");\n" +
                    "</script>");
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}